﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt
{
	// Token: 0x020000C2 RID: 194
	public class TTruncateStatement : TCustomSqlStatement
	{
		// Token: 0x17000146 RID: 326
		// (get) Token: 0x060006FB RID: 1787 RVA: 0x002FFBD2 File Offset: 0x002FDDD2
		// (set) Token: 0x060006FC RID: 1788 RVA: 0x002FFBDA File Offset: 0x002FDDDA
		public virtual TPartitionExtensionClause PartitionExtensionClause
		{
			get
			{
				return this._partitionExtensionClause;
			}
			set
			{
				this._partitionExtensionClause = value;
			}
		}

		// Token: 0x060006FD RID: 1789 RVA: 0x002FFBE3 File Offset: 0x002FDDE3
		public TTruncateStatement(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstTruncate;
		}

		// Token: 0x17000147 RID: 327
		// (get) Token: 0x060006FE RID: 1790 RVA: 0x002FFBFB File Offset: 0x002FDDFB
		// (set) Token: 0x060006FF RID: 1791 RVA: 0x002FFC03 File Offset: 0x002FDE03
		public virtual TObjectName TableName
		{
			get
			{
				return this._tableName;
			}
			set
			{
				this._tableName = value;
			}
		}

		// Token: 0x17000148 RID: 328
		// (get) Token: 0x06000700 RID: 1792 RVA: 0x002FFC0C File Offset: 0x002FDE0C
		// (set) Token: 0x06000701 RID: 1793 RVA: 0x002FFC14 File Offset: 0x002FDE14
		public virtual TObjectNameList Columns
		{
			get
			{
				return this._columns;
			}
			set
			{
				this._columns = value;
			}
		}

		// Token: 0x17000149 RID: 329
		// (get) Token: 0x06000702 RID: 1794 RVA: 0x002FFC1D File Offset: 0x002FDE1D
		// (set) Token: 0x06000703 RID: 1795 RVA: 0x002FFC25 File Offset: 0x002FDE25
		public bool TableKeyword
		{
			get
			{
				return this._tableKeyword;
			}
			set
			{
				this._tableKeyword = value;
			}
		}

		// Token: 0x1700014A RID: 330
		// (get) Token: 0x06000704 RID: 1796 RVA: 0x002FFC2E File Offset: 0x002FDE2E
		// (set) Token: 0x06000705 RID: 1797 RVA: 0x002FFC36 File Offset: 0x002FDE36
		public TSourceToken ImmediateToken
		{
			get
			{
				return this._immediateToken;
			}
			set
			{
				this._immediateToken = value;
			}
		}

		// Token: 0x06000706 RID: 1798 RVA: 0x002FFC40 File Offset: 0x002FDE40
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			base.doParseStatement(psql);
			TTruncateTableSqlNode ttruncateTableSqlNode = (TTruncateTableSqlNode)this.rootNode;
			this._tableKeyword = ttruncateTableSqlNode.TableKeyword;
			this._immediateToken = ttruncateTableSqlNode.ImmediateToken;
			if (ttruncateTableSqlNode.FromTableList != null)
			{
				for (int i = 0; i < ttruncateTableSqlNode.FromTableList.size(); i++)
				{
					TFromTable fromTable = ttruncateTableSqlNode.FromTableList.getFromTable(i);
					TJoin tjoin;
					if (fromTable.FromtableType != ETableSource.join)
					{
						tjoin = new TJoin();
						tjoin.Table = this.analyzeFromTable(fromTable, new bool?(true));
						tjoin.Table.EffectType = ETableEffectType.tetTruncate;
						tjoin.startToken = tjoin.Table.startToken;
						tjoin.endToken = tjoin.Table.endToken;
						tjoin.GSharpSqlParser = this.GSharpSqlParser;
					}
					else
					{
						tjoin = this.analyzeJoin(fromTable.JoinExpr, null, new bool?(true));
						tjoin.doParse(this, ESqlClause.join);
					}
					this.joins.addJoin(tjoin);
				}
			}
			else
			{
				this._tableName = ttruncateTableSqlNode.TableName;
				this.analyzeTablename(this._tableName);
				this.tables[0].EffectType = ETableEffectType.tetTruncate;
			}
			this._partitionExtensionClause = ttruncateTableSqlNode.PartitionExtensionClause;
			this._columns = ttruncateTableSqlNode.Columns;
			return 0;
		}

		// Token: 0x06000707 RID: 1799 RVA: 0x002FFD89 File Offset: 0x002FDF89
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000708 RID: 1800 RVA: 0x002FFD99 File Offset: 0x002FDF99
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x040011CD RID: 4557
		private TPartitionExtensionClause _partitionExtensionClause;

		// Token: 0x040011CE RID: 4558
		private TObjectNameList _columns;

		// Token: 0x040011CF RID: 4559
		private bool _tableKeyword = true;

		// Token: 0x040011D0 RID: 4560
		private TSourceToken _immediateToken;

		// Token: 0x040011D1 RID: 4561
		private TObjectName _tableName;
	}
}
